﻿using System;

namespace Game.StateMachine
{
    public abstract class StateId
    {
        private readonly string _Value;
        
        protected StateId(string value)
        {
            _Value = value;
        }
        
        #region Equals and GetHashCode implementation
        public override int GetHashCode()
        {
            int hashCode = 0;
            unchecked {
                if (_Value != null)
                    hashCode += 1000000007 * _Value.GetHashCode();
            }
            return hashCode;
        }
        
        public override bool Equals(object obj)
        {
            StateId other = obj as StateId;
            if (other == null)
                return false;
            return this._Value == other._Value;
        }
        
        public static bool operator ==(StateId lhs, StateId rhs)
        {
            if (ReferenceEquals(lhs, rhs))
                return true;
            if (ReferenceEquals(lhs, null) || ReferenceEquals(rhs, null))
                return false;
            return lhs.Equals(rhs);
        }
        
        public static bool operator !=(StateId lhs, StateId rhs)
        {
            return !(lhs == rhs);
        }
        #endregion

    }
    
    public class StateIdNone : StateId
    {
        public StateIdNone() : base("None") {}
    }
    
}
